package com.dynamic.mybatisplus.seata.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.dynamic.mybatisplus.seata.mapper.goodsdb.GoodsMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * @author lenovo
 */
@Service
public class GoodsService {
    private static final String SUCCESS = "SUCCESS";
    private static final String FAIL = "FAIL";

    @Resource
    private GoodsMapper goodsMapper;

    @DS("goodsdb")
    public String updateGoodsStock(Long goodsId, int count) {
        int res = goodsMapper.updateGoodsStock(goodsId, count);
        System.out.println("res:" + res);
        if (res > 0) {
            return SUCCESS;
        } else {
            return FAIL;
        }
    }
}
